package com.xzl.org.learning_situation_analysis.service.Impl;

import com.github.pagehelper.PageInfo;
import com.xzl.org.learning_situation_analysis.dao.SubjectMapper;
import com.xzl.org.learning_situation_analysis.entity.Subject;
import com.xzl.org.learning_situation_analysis.service.SubjectService;
import com.xzl.org.learning_situation_analysis.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author 夏智力
 * @FileName SubjectServiceImpl
 * @date 2022/4/21 11:32
 * @Software: IntelliJ IDEA
 */
public class SubjectServiceImpl implements SubjectService {

    @Autowired
    private SubjectMapper subjectMapper;

    @Override
    public int insertSubject(Subject subject) {
        return subjectMapper.insertSubject(subject);
    }

    @Override
    public int delSubject(int id) {
        return subjectMapper.delSubject(id);
    }

    @Override
    public PageInfo<Subject> selectCurrentPageSubject(int currentPage, int pageSize) {
        List<Subject> subjectAll = subjectMapper.selectAll();
        PageInfo<Subject> page = new PageUtil<Subject>().getPage(currentPage,pageSize,subjectAll);

        return page;
    }
}
